package com.smarthome.api.mobile.service;

import java.util.List;

import javax.annotation.Resource;

import com.smarthome.common.mobile.Service;
import com.smarthome.core.operationservicemanager.CompanyLaundryService;
import com.smarthome.core.operationservicemanager.LaundryFeeService;
import com.smarthome.domain.bean.ShLaundryFee;
import com.smarthome.domain.mobile.MobileCodeEnum;
import com.smarthome.domain.mobile.MobileRequest;
import com.smarthome.domain.mobile.MobileResponse;
import com.smarthome.domain.mobile.req.MobileOrdersRequest;
import com.smarthome.domain.vo.boss.Combobox;

/**
 * 
* @ClassName: MobileCompanyLaundryService
* @Description: 洗衣店移动端接口
* @author cyj
* @date 2016年4月6日 下午9:18:21
*
 */
@org.springframework.stereotype.Service("mobile.companyLaundry.service")
public class MobileCompanyLaundryService implements Service<MobileResponse<?>> {

	
	@Resource
	private CompanyLaundryService companyLaundryService;
	
	@Resource
	private LaundryFeeService laundryFeeService;
	
	
	/**
	 * 
	* @Title: getCombobox 
	* @Description: 获取当前小区关联的洗衣店下拉框 
	* @param request
	* @param response
	* void
	* @throws 
	* @author cyj
	 */
	public void getCombobox(MobileRequest request,MobileResponse<List<Combobox>> response) {
		if(request.getAccount().getResidenceId() == null) {
			response.setMobileCodeObj(MobileCodeEnum.LAUNDRY_NOT_RESIDENCE);
			return;
		}
		try {
			List<Combobox> result = companyLaundryService.getCombobox(request.getAccount().getResidenceId());
			response.setData(result);
		}catch(Exception e) {
			response.setMobileCodeObj(MobileCodeEnum.SYSTEM_ERROR);
		}
		
	}
	
	/**
	 * 
	* @Title: getFeeList 
	* @Description: 根据洗衣店id获取洗衣费类型列表 
	* @param request
	* @param response
	* void
	* @throws 
	* @author cyj
	 */
	public void getFeeList(MobileOrdersRequest request,MobileResponse<List<ShLaundryFee>> response) {
		if(request.getCompanyId() == null) {
			response.setMobileCodeObj(MobileCodeEnum.ORDERFEE_NOT_COMPANY);
			return;
		}
		ShLaundryFee laundryFee = new ShLaundryFee();
		laundryFee.setCompanyLaundryId(request.getCompanyId());
		laundryFee.setStatus(1);
		laundryFee.setOrderField("id");
		laundryFee.setOrderFieldType("asc");
		try {
			List<ShLaundryFee> result = laundryFeeService.getList(laundryFee);
			response.setData(result);
		}catch(Exception e) {
			response.setMobileCodeObj(MobileCodeEnum.SYSTEM_ERROR);
		}
	}
}
